//package com.examination.client.config;
//
//import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
//import org.apache.shiro.web.mgt.CookieRememberMeManager;
//import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
//import org.apache.shiro.web.servlet.SimpleCookie;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import javax.servlet.Filter;
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * @Description:
// * @Auther: xiaodong
// * @Date: 2021/10/20
// */
//@Configuration
//public class ShiroConfig {
//    /**
//     * 安全管理器
//     * @param rememberMeManager
//     * @return
//     */
//    @Bean
//    public DefaultWebSecurityManager securityManager(CookieRememberMeManager rememberMeManager){
//        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
//        securityManager.setRememberMeManager(rememberMeManager);
//        securityManager.setRealm(this.shiroDbRealm());
//        return securityManager;
//    }
//
//
//    @Bean
//    public ShiroDbRealm shiroDbRealm(){
//        return new ShiroDbRealm();
//    }
//    /**
//     * rememberMe管理器
//     * @param rememberMeCookie
//     * @return
//     */
//    @Bean
//    public CookieRememberMeManager rememberMeManager(SimpleCookie rememberMeCookie){
//        CookieRememberMeManager rememberMeManager = new CookieRememberMeManager();
//        rememberMeManager.setCookie(rememberMeCookie);
//        return rememberMeManager;
//    }
//    /**
//     * 记住密码Cookie
//     * @return
//     */
//    @Bean
//    public SimpleCookie rememberMeCookie(){
//        SimpleCookie cookie = new SimpleCookie("rememberMe");
//        cookie.setHttpOnly(true);
//        cookie.setMaxAge(60 * 60 * 24 *7);
//        return cookie;
//    }
//
//    @Bean
//    public ShiroFilterFactoryBean shiroFilter(DefaultWebSecurityManager securityManager){
//        ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
//        shiroFilter.setSecurityManager(securityManager);
//        Map<String, Filter> filters = new HashMap<>();
//        filters.put("auth", new ShiroLoginFilter());
//        Map<String, String> map = new HashMap<>();
//        map.put("/login", "anon");
//        map.put("/site/list", "anon");
//        map.put("/site/**", "anon");
//        map.put("/courier/**", "anon");
//        map.put("/userInfo/**","anon");
//        shiroFilter.setFilterChainDefinitionMap(map);
//        shiroFilter.setFilters(filters);
//        return shiroFilter;
//    }
//
//}
